import { TreeNodeData } from '../types';

// 获取所有树节点的key，用于默认展开
export const getAllTreeKeys = (treeData: TreeNodeData[]): string[] => {
  const keys: string[] = [];
  const traverse = (nodes: TreeNodeData[]) => {
    nodes.forEach(node => {
      keys.push(node.key);
      if (node.children && node.children.length > 0) {
        traverse(node.children);
      }
    });
  };
  traverse(treeData);
  return keys;
};
